package AggregationMethod;

import java.util.ArrayList;

import Definitions.NodeClass;
import Sampling.SamplingAbstractClass;

/*****************************************************************
* Name : MultihopMethod
* Aim : This class aims to keep the methods for the MultihopMethod Neighborhood 
* Calculation Function type and inherited from the NeighbourhoodFunction *
* * * Algorithm : The difference between regular countmethod is in multihop the given nodeList
* may be the second degree-ed neighbors.
*****************************************************************/
public class MultihopMethodClass extends NeighbourhoodFunctionAbstractClass 
{
	public MultihopMethodClass(SamplingAbstractClass currentSampling){
		super(currentSampling);
		// TODO Auto-generated constructor stub
		name="MultihopMethod";
	}
	/*****************************************************************
	* Function Name: 	multihopMethod
	* Aim: 				perform the MultihopMethod
	* Inputs: 			ArrayList<Node> node : The neighbors that will be used for the method
	* 					int usePredictOrActual : Predicted Classes or actual classes will be used 
	* 											when choosing neighbors
	* Outputs: 			sumList
	* Data Structures:  ---
	* Algorithms: 		---
	*****************************************************************/
	public ArrayList<Double> getAggregatedNeighbourVector(ArrayList<NodeClass> nodeList)
	{
		
		ArrayList<Double> sumList = new ArrayList<Double>();
		
		for (int k = 0; k < global.classList.size(); k++) 
		{
			sumList.add((double)0);
		}
		for (int k = 0; k < nodeList.size(); k++) 
		{
			int order = -1;
			if(currentSampling.isTheNodeInTestSetForTheFold(nodeList.get(k)))
			{
				order= currentSampling.getClassLabelEstimated(nodeList.get(k));
			}
			else
			{ 
				order = nodeList.get(k).getClassOrder();
			}
			if(order != -1)
				sumList.set(order, (sumList.get(order) + 1));	
		}
		return sumList;
	}
	
}
